package com.jia.leetcode2.string;

/**
 * @program:
 * @description: 子串
 * @author: STU756
 * @create: 2021-03-25 13:58
 */
public class ImplementStr {
    /**
     * 暴力解决
     *
     * @param haystack
     * @param needle
     * @return
     */
    public int strStr(String haystack, String needle) {
       for(int i = 0; ; i++) {
           for(int j = 0; ; j++) {
               if(j == needle.length()) { return i; }
               if(i + j == haystack.length()) {return -1;}
               if(needle.charAt(j)!=haystack.charAt(i+j)) { break; }
           }
       }
    }
}
